package com.zhongke.cotrun.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhongke.cotrun.mapper.NeedBiddingMapper;
import com.zhongke.cotrun.model.pojo.NeedBidding;
import com.zhongke.cotrun.model.pojo.NeedInfo;
import com.zhongke.cotrun.service.NeedBiddingService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NeedBiddingServiceImpl implements NeedBiddingService {
	@Autowired
	NeedBiddingMapper needBiddingMapper;
	 /**
     * 根据需求id查看竞标留言列表
     *
     * @param 需求表主键
     * @return
     */
	public PageInfo selectListByInfoId(Long infoId, Integer pageNum, Integer pageSize){
		PageHelper.startPage(pageNum, pageSize);
		List<NeedBidding> list = needBiddingMapper.selectListByInfoId(infoId);
		PageInfo pageInfo = new PageInfo(list);
	    return pageInfo;
	}
    
    /**
     * 新增
     * @param  对象
     * @return
     */
    public boolean add(NeedBidding NeedBidding){
    	return needBiddingMapper.insert(NeedBidding);
    }
    
    /**
     * 删除
     * @param id 竞标留言主键
     * @return
     */
    public boolean delete(Long id){
    	return needBiddingMapper.deleteByID(id);
    }
    /**
     * 更新状态
     * @param id 竞标留言主键
     * @return
     */
    public boolean updateState(Long id){
    	return needBiddingMapper.updateState(id);
    }
}
